import { createRouter, createWebHashHistory } from 'vue-router'
import { usePlayerStore } from '../stores/player'
import Home from '../views/Home.vue'
import Cultivation from '../views/Cultivation.vue'
import Inventory from '../views/Inventory.vue'
import Exploration from '../views/Exploration.vue'
import Achievements from '../views/Achievements.vue'
import Settings from '../views/Settings.vue'
import GM from '../views/GM.vue'
import Alchemy from '../views/Alchemy.vue'
import Dungeon from '../views/Dungeon.vue'
import PetGacha from '../views/PetGacha.vue'

const routes = [
    {
        path: '/',
        name: 'Home',
        component: Home
    },
    {
        path: '/cultivation',
        name: 'Cultivation',
        component: Cultivation
    },
    {
        path: '/inventory',
        name: 'Inventory',
        component: Inventory
    },
    {
        path: '/exploration',
        name: 'Exploration',
        component: Exploration
    },
    {
        path: '/achievements',
        name: 'Achievements',
        component: Achievements
    },
    {
        path: '/settings',
        name: 'Settings',
        component: Settings
    },
    {
        path: '/gm',
        name: 'gm',
        component: GM,
        beforeEnter: (to, from, next) => {
            const playerStore = usePlayerStore()
            if (!playerStore.isGMMode) {
                next('/cultivation')
            } else {
                next()
            }
        }
    },
    { 
        path: '/alchemy', 
        name: 'alchemy', 
        component: Alchemy
    },
    { 
        path: '/dungeon', 
        name: 'Dungeon', 
        component: Dungeon
    },
    {
        path: '/pet-gacha',
        name: 'PetGacha',
        component: PetGacha
    }
]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

export default router